package com.xxxx.server.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.xxxx.server.pojo.Role;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author Ding Yi
 * @since 2021-07-07
 */
@Component("RoleMapper")
public interface RoleMapper extends BaseMapper<Role> {

    /***
     * 根据用户id查询角色列表
     * @param adminId
     * @return
     */

    @Select("        SELECT" +
            "            r.id," +
            "            r.`name`," +
            "            r.nameZh" +
            "        FROM" +
            "            t_role AS r" +
            "            LEFT JOIN t_admin_role AS ar ON r.id = ar.rid" +
            "        WHERE" +
            "            ar.adminId = #{adminId}")
    List<Role> getRoles(Integer adminId);
}
